package com.oa.xinxi.dao;

import com.oa.xinxi.entity.PPE;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface PPEMapper {
    @Delete({
        "delete from gdzc",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into gdzc (id, name, ",
        "model, number, price, ",
        "sum_price, buy_time, baoxiu, ",
        "syqk, syqk_detail, ",
        "address, dep_id, ",
        "zerenren, creator, ",
        "createtime, updator, ",
        "updatetime)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{model,jdbcType=VARCHAR}, #{number,jdbcType=INTEGER}, #{price,jdbcType=DOUBLE}, ",
        "#{sumPrice,jdbcType=DOUBLE}, #{buyTime,jdbcType=DATE}, #{baoxiu,jdbcType=VARCHAR}, ",
        "#{syqk,jdbcType=VARCHAR}, #{syqkDetail,jdbcType=VARCHAR}, ",
        "#{address,jdbcType=VARCHAR}, #{depId,jdbcType=INTEGER}, ",
        "#{zerenren,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, ",
        "#{createtime,jdbcType=TIMESTAMP}, #{updator,jdbcType=VARCHAR}, ",
        "#{updatetime,jdbcType=TIMESTAMP})"
    })
    int insert(PPE record);

    @InsertProvider(type=PPESqlProvider.class, method="insertSelective")
    int insertSelective(PPE record);

    @Select({
        "select",
        "id, name, model, number, price, sum_price, buy_time, baoxiu, syqk, syqk_detail, ",
        "address, dep_id, zerenren, creator, createtime, updator, updatetime",
        "from gdzc",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="model", property="model", jdbcType=JdbcType.VARCHAR),
        @Result(column="number", property="number", jdbcType=JdbcType.INTEGER),
        @Result(column="price", property="price", jdbcType=JdbcType.DOUBLE),
        @Result(column="sum_price", property="sumPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="buy_time", property="buyTime", jdbcType=JdbcType.DATE),
        @Result(column="baoxiu", property="baoxiu", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk", property="syqk", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk_detail", property="syqkDetail", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="dep_id", property="depId", jdbcType=JdbcType.INTEGER),
        @Result(column="zerenren", property="zerenren", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP)
    })
    PPE selectByPrimaryKey(Integer id);

    @UpdateProvider(type=PPESqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PPE record);

    @Update({
        "update gdzc",
        "set name = #{name,jdbcType=VARCHAR},",
          "model = #{model,jdbcType=VARCHAR},",
          "number = #{number,jdbcType=INTEGER},",
          "price = #{price,jdbcType=DOUBLE},",
          "sum_price = #{sumPrice,jdbcType=DOUBLE},",
          "buy_time = #{buyTime,jdbcType=DATE},",
          "baoxiu = #{baoxiu,jdbcType=VARCHAR},",
          "syqk = #{syqk,jdbcType=VARCHAR},",
          "syqk_detail = #{syqkDetail,jdbcType=VARCHAR},",
          "address = #{address,jdbcType=VARCHAR},",
          "dep_id = #{depId,jdbcType=INTEGER},",
          "zerenren = #{zerenren,jdbcType=VARCHAR},",
          "creator = #{creator,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updator = #{updator,jdbcType=VARCHAR},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(PPE record);
    @Select({
        "select",
        "id, name, model, number, price, sum_price, buy_time, baoxiu, syqk, syqk_detail, ",
        "address, dep_id, zerenren, creator, createtime, updator, updatetime",
        "from gdzc"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="model", property="model", jdbcType=JdbcType.VARCHAR),
        @Result(column="number", property="number", jdbcType=JdbcType.INTEGER),
        @Result(column="price", property="price", jdbcType=JdbcType.DOUBLE),
        @Result(column="sum_price", property="sumPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="buy_time", property="buyTime", jdbcType=JdbcType.DATE),
        @Result(column="baoxiu", property="baoxiu", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk", property="syqk", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk_detail", property="syqkDetail", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="dep_id", property="depId", jdbcType=JdbcType.INTEGER),
        @Result(column="zerenren", property="zerenren", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<PPE> findAll();
    @Select({
        "select",
        "id, name, model, number, price, sum_price, buy_time, baoxiu, syqk, syqk_detail, ",
        "address, dep_id, zerenren, creator, createtime, updator, updatetime",
        "from gdzc",
        "where dep_id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="model", property="model", jdbcType=JdbcType.VARCHAR),
        @Result(column="number", property="number", jdbcType=JdbcType.INTEGER),
        @Result(column="price", property="price", jdbcType=JdbcType.DOUBLE),
        @Result(column="sum_price", property="sumPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="buy_time", property="buyTime", jdbcType=JdbcType.DATE),
        @Result(column="baoxiu", property="baoxiu", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk", property="syqk", jdbcType=JdbcType.VARCHAR),
        @Result(column="syqk_detail", property="syqkDetail", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="dep_id", property="depId", jdbcType=JdbcType.INTEGER),
        @Result(column="zerenren", property="zerenren", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<PPE> findByDepId(Integer id);
    @Select({
    	"SELECT id from dep WHERE `name`=#{name}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true)
    })
    Integer findDepIdByName(String name);
}